# 案例2 【发送表单格式的post请求】，使用requests库，完成登录接口调用，返回“验证码错误”即可
# 请求地址是： http://127.0.0.1/index.php?m=Home&c=User&a=do_login&t=0.999687125390627
# 请求头：Content-Type: application/x-www-form-urlencoded;charset=UTF-8
# 请求体：username=13800000000&password=123456&verify_code=8888
# 导包
import requests
# 验证码获取
resp_v=requests.get("http://127.0.0.1/index.php?m=Home&c=User&a=verify&t=0.2788920881978042")
my_cookie=resp_v.cookies
# 发送j接口请求
resp_l=requests.post("http://127.0.0.1/index.php?m=Home&c=User&a=do_login&t=0.2788920881978042",
                   headers={"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"},
                   data={"username":"13800000000","password":"123456","verify_code":"8888"},
                     cookies=my_cookie)
# 查看响应数据
print(resp_l.json())


